<basics2:ChildWindow x:Class="Rage.UI.ItemBrowser" Title="Item Browser"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:data="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:basics="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:basics2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
  xmlns:Rage="clr-namespace:Rage;assembly=Rage.Base.WPF"
  mc:Ignorable="d" Height="400" Width="600">

  <basics2:ChildWindow.Resources>
    <DataTemplate x:Key="DataTemplateItemGridRowDetails">
      <DockPanel Background="White" LastChildFill="True">
        <Image Height="32" Margin="5,5,5,5" Width="32" Source="{Binding Converter={StaticResource IconPathConverter}, ConverterParameter=IconPath}" DockPanel.Dock="Left" />
        <Rectangle Height="20" Margin="4" Width="20" Fill="{Binding Converter={StaticResource ModColorConverter}, ConverterParameter=1}" DockPanel.Dock="Right" />
        <Rectangle Height="20" Margin="4" Width="20" Fill="{Binding Converter={StaticResource ModColorConverter}, ConverterParameter=2}" DockPanel.Dock="Right" />
        <Rectangle Height="20" Margin="4" Width="20" Fill="{Binding Converter={StaticResource ModColorConverter}, ConverterParameter=3}" DockPanel.Dock="Right" />
        <Rectangle Height="20" Margin="4" Width="20" Fill="{Binding Converter={StaticResource ModColorConverter}, ConverterParameter=4}" DockPanel.Dock="Right" />
        <Rectangle Height="20" Margin="4" Width="20" Fill="{Binding Converter={StaticResource ModColorConverter}, ConverterParameter=5}" DockPanel.Dock="Right" />
        <StackPanel Margin="5" VerticalAlignment="Center">
          <TextBlock Text="{Binding Stats}" TextWrapping="Wrap" />
          <!--<TextBlock Text="{Binding LocationInfo}" TextWrapping="Wrap"/>-->
        </StackPanel>
      </DockPanel>
    </DataTemplate>
    <DataTemplate x:Key="DataTemplateItemGridCellName">
      <TextBlock Padding="5,0,5,0" FontWeight="Bold" Foreground="{Binding Converter={StaticResource ItemQualityConverter}}" Text="{Binding Name}" VerticalAlignment="Center" />
    </DataTemplate>
    <Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type GroupItem}">
            <Expander x:Name="exp" IsExpanded="True" Background="PowderBlue" Foreground="Black" BorderBrush="AliceBlue">
              <Expander.Header>
                <TextBlock Text="{Binding Name}" />
              </Expander.Header>
              <ItemsPresenter />
            </Expander>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </basics2:ChildWindow.Resources>

  <Grid x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <DockPanel Margin="2" LastChildFill="True">
      <TextBlock Margin="2" Text="Name, Id or Source:" VerticalAlignment="Center" DockPanel.Dock="Left" />
      <CheckBox x:Name="CK_UseRegex" Checked="CK_UseRegex_CheckedChanged" Content="Use Regex" Unchecked="CK_UseRegex_CheckedChanged" VerticalAlignment="Center" DockPanel.Dock="Right" />
      <TextBox x:Name="NameText" Margin="2" TextChanged="NameText_TextChanged" DockPanel.Dock="Right" />
    </DockPanel>
    <Expander Grid.Row="1" Margin="4,2" Header="Filters">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <StackPanel>
          <StackPanel Orientation="Horizontal" d:LayoutOverrides="Width" Visibility="Collapsed">
            <TextBlock Text="Show Per Page:" Margin="2" VerticalAlignment="Center" />
            <TextBox x:Name="TB_ShowPerPage" Margin="2" Width="45" TextChanged="ShowPerPageChanged" Text="25" CharacterCasing="Upper" MaxLength="5" MaxLines="1" />
          </StackPanel>
          <StackPanel Orientation="Horizontal" d:LayoutOverrides="Width">
            <TextBlock Margin="2" Width="50" HorizontalAlignment="Left" Text="Level:" TextAlignment="Right" TextWrapping="Wrap" VerticalAlignment="Center" />
            <TextBox x:Name="MinLevelText" Margin="2" Width="35" HorizontalAlignment="Left" TextChanged="LevelChanged" VerticalAlignment="Center" />
            <TextBlock Margin="2,2,4,2" HorizontalAlignment="Left" Text="-" TextWrapping="Wrap" VerticalAlignment="Center" />
            <TextBox x:Name="MaxLevelText" Margin="2" Width="35" HorizontalAlignment="Left" TextChanged="LevelChanged" VerticalAlignment="Center" />
          </StackPanel>
          <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
            <TextBlock Margin="2" Width="50" HorizontalAlignment="Left" Text="Class:" TextAlignment="Right" TextWrapping="Wrap" VerticalAlignment="Center" />
            <ComboBox x:Name="ClassCombo" Margin="2" Width="110" HorizontalAlignment="Left" SelectionChanged="FilterChanged" VerticalAlignment="Center">
              <ComboBoxItem Content=" " />
              <ComboBoxItem Content="Juggernaut" />
              <ComboBoxItem Content="Marauder" />
              <ComboBoxItem Content="Assassin" />
              <ComboBoxItem Content="Sorcerer" />
              <ComboBoxItem Content="Powertech" />
              <ComboBoxItem Content="Mercenary" />
              <ComboBoxItem Content="Operative" />
              <ComboBoxItem Content="Sniper" />
              <ComboBoxItem Content="Guardian" />
              <ComboBoxItem Content="Sentinel" />
              <ComboBoxItem Content="Shadow" />
              <ComboBoxItem Content="Sage" />
              <ComboBoxItem Content="Vanguard" />
              <ComboBoxItem Content="Commando" />
              <ComboBoxItem Content="Scoundrel" />
              <ComboBoxItem Content="Gunslinger" />
            </ComboBox>
          </StackPanel>
        </StackPanel>
        <ListBox x:Name="BindList" Grid.Column="1" Grid.RowSpan="3" Height="120" Margin="2" SelectionChanged="FilterChanged" SelectionMode="Multiple">
          <ListBoxItem Content="None" />
          <ListBoxItem Content="BoP" />
          <ListBoxItem Content="BoE" />
          <ListBoxItem Content="BoA" />
          <ListBoxItem Content="BoU" />
        </ListBox>
        <ListBox x:Name="SlotList" Grid.Column="2" Grid.RowSpan="3" Height="120" Margin="2" SelectionChanged="FilterChanged" SelectionMode="Multiple">
          <ListBoxItem Content="None" />
          <ListBoxItem Content="Head" />
          <ListBoxItem Content="Chest" />
          <ListBoxItem Content="Hands" />
          <ListBoxItem Content="Waist" />
          <ListBoxItem Content="Legs" />
          <ListBoxItem Content="Feet" />
          <ListBoxItem Content="Implant" />
          <ListBoxItem Content="Wrist" />
          <ListBoxItem Content="Relic" />
          <ListBoxItem Content="One Hand" />
          <ListBoxItem Content="Main Hand" />
          <ListBoxItem Content="Off Hand" />
          <ListBoxItem Content="Armoring" />
          <ListBoxItem Content="Barrel" />
          <ListBoxItem Content="Hilt" />
          <ListBoxItem Content="Mod" />
          <ListBoxItem Content="Enhancement" />
          <ListBoxItem Content="Color Crystal" />
          <ListBoxItem Content="Augment" />
        </ListBox>
        <ListBox x:Name="TypeList" Grid.Column="3" Grid.RowSpan="3" Height="120" Margin="2" SelectionChanged="FilterChanged" SelectionMode="Multiple">
          <ListBoxItem Content="None" />
          <ListBoxItem Content="Light" />
          <ListBoxItem Content="Medium" />
          <ListBoxItem Content="Heavy" />
          <ListBoxItem Content="Ear" />
          <ListBoxItem Content="Implant" />
          <ListBoxItem Content="Relic" />
          <ListBoxItem Content="Vibroknife" />
          <ListBoxItem Content="Vibrosword" />
          <ListBoxItem Content="Lightsaber" />
          <ListBoxItem Content="Double-Bladed Lightsaber" />
          <ListBoxItem Content="Techblade" />
          <ListBoxItem Content="Electrostaff" />
          <ListBoxItem Content="Tech Staff" />
          <ListBoxItem Content="Blaster Rifle" />
          <ListBoxItem Content="Assault Cannon" />
          <ListBoxItem Content="Sniper Rifle" />
          <ListBoxItem Content="Blaster Pistol" />
          <ListBoxItem Content="Shotgun" />
          <ListBoxItem Content="Fous" />
          <ListBoxItem Content="Shield" />
          <ListBoxItem Content="Generator" />
        </ListBox>
        <ListBox x:Name="QualityList" Grid.Column="4" Grid.RowSpan="3" Height="120" Margin="2" SelectionChanged="FilterChanged" SelectionMode="Multiple">
          <ListBoxItem Content="Temp" />
          <ListBoxItem Content="Cheap" />
          <ListBoxItem Content="Standard" />
          <ListBoxItem Content="Premium" />
          <ListBoxItem Content="Prototype" />
          <ListBoxItem Content="Artifact" />
          <ListBoxItem Content="Legendary" />
        </ListBox>
      </Grid>
    </Expander>
    <DataGrid x:Name="ItemGrid" Grid.Row="2" Margin="4" AreRowDetailsFrozen="True" AutoGenerateColumns="False" ItemsSource="{Binding}"
              CanUserReorderColumns="True" CanUserResizeColumns="True" CanUserSortColumns="True" GridLinesVisibility="Horizontal" Sorting="ItemGrid_Sorting"
              HorizontalAlignment="Stretch" IsReadOnly="True" RowDetailsTemplate="{StaticResource DataTemplateItemGridRowDetails}"
              RowDetailsVisibilityMode="VisibleWhenSelected" SelectionChanged="ItemGrid_SelectionChanged" SelectionMode="Single" HeadersVisibility="Column">
      <DataGrid.ContextMenu>
        <ContextMenu>
          <MenuItem Header="Add" Click="AddButton_Click" />
          <MenuItem Header="Edit" Click="EditButton_Click" />
          <MenuItem Header="Refresh" Click="RefreshButton_Click" />
          <MenuItem Header="Delete" Click="DeleteButton_Click" />
        </ContextMenu>
      </DataGrid.ContextMenu>
      <DataGrid.GroupStyle>
        <GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
          <GroupStyle.Panel>
            <ItemsPanelTemplate>
              <DataGridRowsPresenter/>
            </ItemsPanelTemplate>
          </GroupStyle.Panel>
        </GroupStyle>
      </DataGrid.GroupStyle>
      <DataGrid.Columns>
        <DataGridTemplateColumn CellTemplate="{StaticResource DataTemplateItemGridCellName}" Header="Name" SortMemberPath="Name" />
        <DataGridTextColumn Binding="{Binding Type}" Header="Type" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding Slot}" Header="Slot" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding Id}" Header="Item ID" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding ItemLevel}" Header="Level" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding Rating}" Header="Rating" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding Bind}" Header="Bind" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding ItemArmoringHiltBarrelType}" Header="A/B/H" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding ItemModType}" Header="Mod" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding ItemEnhancementType}" Header="Enh" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding ItemColorCrystalType}" Header="ColCr" IsReadOnly="True" />
        <DataGridTextColumn Binding="{Binding GetFullLocationDesc}" Header="Source" IsReadOnly="True" />
      </DataGrid.Columns>
    </DataGrid>
    <Grid Grid.Row="3" Grid.ColumnSpan="3" VerticalAlignment="Center">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
      </Grid.ColumnDefinitions>

      <Button x:Name="BT_First" Grid.Column="0" Margin="4" Click="OnFirstClicked" Content="|&lt;" IsEnabled="True" Visibility="Collapsed" />
      <Button x:Name="BT_Prev" Grid.Column="1" Margin="4" Click="OnPreviousClicked" Content="&lt;" IsEnabled="True" Visibility="Collapsed" />
      <TextBlock x:Name="LB_CurPage" Grid.Column="2" Margin="4" VerticalAlignment="Center" Text="Page {0} of {1}" Visibility="Collapsed" />
      <Button x:Name="BT_Next" Grid.Column="3" Margin="4" Click="OnNextClicked" Content="&gt;" IsEnabled="True" Visibility="Collapsed" />
      <Button x:Name="BT_Last" Grid.Column="4" Margin="4" Click="OnLastClicked" Content="&gt;|" IsEnabled="True" Visibility="Collapsed" />
      <Button x:Name="AddButton" Grid.Column="6" Margin="4" Width="50" Click="AddButton_Click" Content="Add" IsEnabled="True" />
      <Button x:Name="EditButton" Grid.Column="7" Margin="4" Width="50" Click="EditButton_Click" Content="Edit" IsEnabled="False" />
      <Button x:Name="RefreshButton" Grid.Column="8" Margin="4" Width="50" Click="RefreshButton_Click" Content="Refresh" IsEnabled="False" />
      <Button x:Name="DeleteButton" Grid.Column="9" Margin="4" Width="50" Click="DeleteButton_Click" Content="Delete" IsEnabled="False" />
      <Button x:Name="BT_LargeView" Grid.Column="11" Margin="4" Width="75" Click="BT_LargeView_Click" Content="Large View" Visibility="Visible" d:LayoutOverrides="Height, VerticalMargin" />
      <Button x:Name="BT_SmallView" Grid.Column="12" Margin="4" Width="75" Click="BT_SmallView_Click" Content="Small View" Visibility="Collapsed" d:LayoutOverrides="Height, VerticalMargin" />
      <Button x:Name="DoneButton" Grid.Column="13" Margin="4" Width="75" Click="DoneButton_Click" Content="Done" d:LayoutOverrides="Height, VerticalMargin" />
    </Grid>
  </Grid>
</basics2:ChildWindow>